import axios from '~/axios'

// 添加指标购买申请
export function addPurchaseApplicationApi(data) {
    return axios.post('/basic/lindi/purchaseApplication/addPurchaseApplication', data)
}

// 删除指标购买申请
export function deletePurchaseApplicationByPurchaseApplicationIdApi(purchaseApplicationId) {
    return axios({
        method: 'DELETE',
        url: '/basic/lindi/purchaseApplication/deletePurchaseApplicationByPurchaseApplicationId',
        params: {
            purchaseApplicationId: purchaseApplicationId
        }
    })
}

// 修改指标购买申请
export function updatePurchaseApplicationByPurchaseApplicationIdApi(data) {
    return axios.put('/basic/lindi/purchaseApplication/updatePurchaseApplicationByPurchaseApplicationId', data)
}

// 分页查询指标购买申请列表
export function getPagePurchaseApplicationListApi(params) {
    return axios({
        method: 'GET',
        url: '/basic/lindi/purchaseApplication/getPagePurchaseApplicationList',
        params: params
    })
}

// 根据ID查询指标购买申请详情
export function getPurchaseApplicationByPurchaseApplicationIdApi(purchaseApplicationId) {
    return axios.get(`/basic/lindi/purchaseApplication/getPurchaseApplicationByPurchaseApplicationId/${purchaseApplicationId}`)
}

/**
 * 删除指标购买申请文件 -> 根据文件ID删除
 * @param {number} fileId - 文件ID
 * @returns {Promise} API响应
 */
export const deletePurchaseApplicationFileByFileIdApi = (fileId) => {
    return axios({
        url: '/lindi/purchaseApplication/deletePurchaseApplicationFileByFileId',
        method: 'post',
        params: {
            fileId: fileId
        }
    })
}

/**
 * 审批指标购买申请
 * @param {Object} approvalData - 审批数据
 * @returns {Promise} API响应
 */
export const approvePurchaseApplicationApi = (approvalData) => {
    return axios({
        url: '/basic/lindi/purchaseApplication/approvePurchaseApplication',
        method: 'post',
        data: approvalData
    })
}